<?php

if($_POST["Email"]==null){
    $email="";
}else{
$email= $_POST["Email"];
}
    

require '../configSite/db/DBConexion.php';
$con = new DBConexion(2);

require 'model/model_login.php';
$model = new model_login($con->db);
 
$correo = $model->getCorreo($email);
if($correo==null){
    header("Location:index.php");
}if($correo!=NULL){
 
 
if($correo[0]["strCorreo"]==$email){
require '../Recursos/libs/PHPMailer/class.phpmailer.php';
date_default_timezone_set('Etc/UTC');

//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->IsSMTP();

//$mail->SMTPDebug  = 2;
//Ask for HTML-friendly debug output
//$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host       = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port       = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth   = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username   = "progra4latina@gmail.com";
//Password to use for SMTP authentication
$mail->Password   = "12progra12";
//Set who the message is to be sent from
$mail->SetFrom('progra4latina@gmail.com', 'NCC LAW');
//Set an alternative reply-to address
//$mail->AddReplyTo('replyto@example.com','First Last');
//Set who the message is to be sent to
$mail->AddAddress($correo[0]["strCorreo"],"Usuario");
//Set the subject line
$mail->Subject = 'Solicitud de recuperacion de contrasena';
//Read an HTML message body from an external file, convert referenced images to embedded, convert HTML into a basic plain-text alternative body


$mail->Body="<h1>Recuperacion de contrasena</h1>
              <br/>
              <p>Su usuario es:</p> ".
              "<p>".$correo[0]["strNombreUsuario"]."</p>
              <p>Su contrasena es:</p> ".
              "<p>".$correo[0]["strPassword"]."</p>
              <p>Saludos,</p>
              <p>NCC LAW</p>";
    
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->AddAttachment('images/phpmailer_mini.gif');

//Send the message, check for errors
$mail->Send();
  

}header("Location:index.php");}

?>
